package com.qf.service.impl;

import com.qf.entity.Coupon;
import com.qf.mapper.custom.CouponCustomMapper;
import com.qf.service.CouponCustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description TODO
 * @Author 刘珈玮
 * @Date 2020/7/25 11:15
 */
@Service
public class CouponCustomServiceImpl implements CouponCustomService {
    @Autowired
    private CouponCustomMapper couponCustomMapper;

    /**
     * 根据当前用户id查询其所拥有的所有优惠券信息
     * @param userId 用户id
     * @return 返回一个Coupon实体类型的list集合
     */
    @Override
    public List<Coupon> getAllCouponInfoById(Integer userId) {
        if (userId != null) {
            List<Coupon> coupons = couponCustomMapper.selectCouponById(userId);
            if (coupons != null) {
                return coupons;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
}
